/**
 * Copyright (C) 2010  Hylke van der Schaafs
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package hextd.core;

import hextd.creep.HexTDCreep;
import hextd.creep.HexTDCreepData;
import hextd.tower.FactoryTower;
import hextd.map.JsonTowerOptions;
import hextd.tower.HexTDTower;
import java.util.EnumMap;
import java.util.Map;
import com.usoog.tdcore.gamestate.GameStateDefault;
import com.usoog.tdcore.player.Player;
import hextd.hex.HexTile;

public class GameStateImplementation extends GameStateDefault<HexTDCreepData, HexTDCreep, HexTDTower, HexTile> {

	private Map<FactoryTower.type, JsonTowerOptions> towerOptions = new EnumMap<FactoryTower.type, JsonTowerOptions>(FactoryTower.type.class);
	private String title;
	private String info;
	private String backGroundImage;

	public GameStateImplementation(GameManagerImplementation gm, GameGridImplementation grid) {
		super(gm, grid);
	}

	public void resetTowerOptions() {
		towerOptions.clear();
	}

	public void setTowerOptions(FactoryTower.type type, JsonTowerOptions options) {
		towerOptions.put(type, options);
	}

	public JsonTowerOptions getTowerOptions(FactoryTower.type type) {
		return towerOptions.get(type);
	}

	public boolean newTowerAllowed(FactoryTower.type type, Player player) {
		JsonTowerOptions options = towerOptions.get(type);
		if (options == null) {
			return true;
		}
		return options.getMaxCount() > player.getTowerCount(type.code);
	}

	public void setLevelTitle(String title) {
		this.title = title;
	}

	public void setLevelInfo(String info) {
		this.info = info;
	}

	public void setBackgroundImage(String backGroundImage) {
		this.backGroundImage = backGroundImage;
	}

	public String getBackGroundImage() {
		return backGroundImage;
	}
}
